package com.wing.member.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;

/**
 * 会员登录记录
 *
 * @author
 */
@Data
@TableName("mem_member_login_log")
public class MemberLoginLog extends BaseEntity<MemberLoginLog> {

    public enum IsDeleted implements IEnum<Integer> {

        no(0, "否"),
        yes(1, "是");

        private int code;
        private String desc;

        IsDeleted(int code, String desc){
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        @JsonValue
        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 会员ID
     */
    private Long memberId;

    /**
     * ip地址
     */
    private String ipAddress;

    /**
     * 登录次数
     */
    private Integer num;

    /**
     * 会员用户名
     */
    @TableField(exist = false)
    private String memberUsername;

    /**
     * 会员邮箱
     */
    @TableField(exist = false)
    private String email;

    public MemberLoginLog(){}

    public MemberLoginLog(
        Long memberId,
        String ipAddress
    ) {
        this.memberId = memberId;
        this.ipAddress = ipAddress;
    }

}
